/**
 * <p>
 * Created on 2006-4-11 17:30:32 <br>
 * Copyright (c) 2006, All rights reserved.
 * </p>
 * @author Widen
 */
package com.widen.prima.editor.finance;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;

import com.widen.prima.Application;
import com.widen.prima.IImageKeys;
import com.widen.prima.finance.entites.AccountSubjectBo;
import com.widen.prima.model.ManageSubjectRoot;

public class ManageSubjectTreeLabelProvider
    extends LabelProvider
{
    private Image labelImage;

    public String getText(Object obj)
    {
        if (obj instanceof ManageSubjectRoot)
        {
            return "";
        } else if (obj instanceof AccountSubjectBo)
        {
            return ((AccountSubjectBo) obj).getSubjectName();
        }
        return null;
    }

    public Image getImage(Object obj)
    {
        String imgKey = IImageKeys.SUBJECT;
        // if (obj instanceof AccountSubjectBo)
        // {
        // AccountSubjectBo subjectBo = (AccountSubjectBo) obj;
        // int countOfChildren = subjectBo.getChildrenSize().intValue();
        // if (countOfChildren > 0)
        // {
        // imgKey = IImageKeys.SUBJECT;
        // }
        // }
        labelImage = AbstractUIPlugin.imageDescriptorFromPlugin(
            Application.PLUGIN_ID,
            imgKey).createImage();
        return labelImage;
    }

    public void dispose()
    {
        labelImage.dispose();
    }
}
